<?php

class CategoriesController extends AppController {

	function index() {
		$conditions = array(
						'contain' => false,
		    			'order' => array('Category.name'),
				    	);
		
		//This will get current user 
		$curruser = $this->Session->read('User');

		//If not a superuser, listing will only be for his organization as well as base data!
		if ( $curruser['User']['access_level'] > 0 ) {

			$conditions['conditions'] = array('Organization.id' => array(0, $curruser['User']['organization_id']));
		
		}
		
		$categories = $this->Category->find('all', 
			$conditions);
		
		$this->set('categories', $categories);
		
	}

	function update( $id = null , $action = null) {
		
		$this->set('id', $id);
		$this->set('action', $action);
		
	}

	function beforeRender() {
		parent::beforeRender();
		$this->set('module', 'Category');
	}
	
}
?>